package com.wang.wemedia.controller.v1;

import com.wang.common.model.dto.ResponseResult;
import com.wang.wemedia.api.model.dto.WmMaterialDto;
import com.wang.wemedia.service.WmMaterialService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 文庄素材管理接口
 *
 * @author: wangning
 * @date: 2024/1/11 18:23
 */
@RestController
@RequestMapping("/api/v1/material")
@RequiredArgsConstructor
public class WmMaterialController {

    private final WmMaterialService wmMaterialService;

    /**
     * 素材图片上传 开始只留了6张图 1-6
     *
     * @param multipartFile 图片
     * @return ResponseResult
     * @throws IOException
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) throws IOException {
        return wmMaterialService.uploadPicture(multipartFile);
    }

    /**
     * 图片列表展示
     *
     * @param dto 前端传参 收藏及分页
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto){
        return wmMaterialService.findList(dto);
    }

}
